﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <base href="<%=basePath%>">
    <!-- jsp文件头和头部 -->
    <%@ include file="../admin/top.jsp" %>
</head>
<body>
<div class="container-fluid" id="main-container">

    <div id="page-content" class="clearfix">
        <div class="row-fluid">
            <div class="row-fluid">
                <!-- 检索  -->
                <form action="channelArea/list" method="post" name="userForm" id="userForm">
                    <input type="hidden" name="menuId" value="${page.menuId}">
                    <table style="width: 250px; float: right">
                        <tr>
                            <td style="vertical-align:top;">
                                <c:if test="${(empty uesr.channelArea.level or user.channelArea.level < 5) and fn:contains(butSet, 'add')}">
                                    <a class="btn btn-small btn-success" onclick="add();">新增</a>
                                </c:if>
                            </td>
                        </tr>
                    </table>

                    <table id="table_report" class="table table-striped table-bordered table-hover">
                        <thead>
                        <tr role="row">
                            <th style="width: 250px;">ID</th>
                            <th style="width: 380px;">区域名称</th>
                            <th style="width: 380px;">上级名称</th>
                            <th style="width: 380px;">所处级别</th>
                            <th class="center" style="width: 80px;">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <!-- 开始循环 -->
                        <c:choose>
                            <c:when test="${not empty channelAreas}">
                                <c:forEach items="${channelAreas}" var="channelArea">
                                    <tr>
                                        <td style="width: 250px;">${channelArea.id}</td>
                                        <td onclick="levelControl('${channelArea.id}')"
                                            style="width: 380px; cursor: pointer">
                                            <c:if test="${not empty channelArea.channelAreaList}">
                                                <span style="margin-right: 15px;cursor: pointer" id="${channelArea.id}">△</span>
                                            </c:if>
                                                ${channelArea.name }
                                        </td>
                                        <td style="width: 380px;">${channelArea.pname}</td>
                                        <td style="width: 380px;">一级</td>
                                        <td style="width: 80px;">
                                        </td>
                                    </tr>
                                    <c:forEach items="${channelArea.channelAreaList}" var="channelArea2">
                                        <tr style="display: none" class="${channelArea.id}">
                                            <td style="width: 250px;">${channelArea2.id}</td>
                                            <td onclick="levelControl('${channelArea2.id}')"
                                                style="padding-left: 28px; width: 380px;  cursor: pointer">
                                                <c:if test="${not empty channelArea2.channelAreaList}">
                                                    <span style="margin-right: 15px;cursor: pointer"
                                                          id="${channelArea2.id}">△</span>
                                                </c:if>
                                                    ${channelArea2.name }
                                            </td>
                                            <td style="width: 380px;">${channelArea2.pname}</td>
                                            <td style="width: 380px;">二级</td>
                                            <td style="width: 80px;">
                                                <div class='hidden-phone visible-desktop btn-group'>
                                                    <c:if test="${fn:contains(butSet, 'edit')}">
                                                        <a class='btn btn-mini btn-info' title="编辑"
                                                           onclick="edit('${channelArea2.id }');">
                                                            编辑
                                                        </a>
                                                    </c:if>
                                                    <c:if test="${fn:contains(butSet, 'del')}">
                                                        <a class='btn btn-mini btn-danger' title="删除"
                                                           onclick="del('${channelArea2.id }','${channelArea2.name }');">
                                                            删除
                                                        </a>
                                                    </c:if>
                                                </div>
                                            </td>
                                        </tr>
                                        <c:forEach items="${channelArea2.channelAreaList}" var="channelArea3">
                                            <tr style="display: none" class="${channelArea.id} ${channelArea2.id}">
                                                <td style="width: 250px;">${channelArea3.id}</td>
                                                <td onclick="levelControl('${channelArea3.id}')"
                                                    style="padding-left: 48px; width: 380px; cursor: pointer">
                                                    <c:if test="${not empty channelArea3.channelAreaList}">
                                                        <span style="margin-right: 15px;cursor: pointer"
                                                              id="${channelArea3.id}">△</span>
                                                    </c:if>
                                                        ${channelArea3.name }
                                                </td>
                                                <td style="width: 380px;">${channelArea3.pname}</td>
                                                <td style="width: 380px;">三级</td>
                                                <td style="width: 80px;">
                                                    <div class='hidden-phone visible-desktop btn-group'>
                                                        <c:if test="${fn:contains(butSet, 'edit')}">
                                                            <a class='btn btn-mini btn-info' title="编辑"
                                                               onclick="edit('${channelArea3.id }');">
                                                                编辑
                                                            </a>
                                                        </c:if>
                                                        <c:if test="${fn:contains(butSet, 'del')}">
                                                            <a class='btn btn-mini btn-danger' title="删除"
                                                               onclick="del('${channelArea3.id }','${channelArea3.name }');">
                                                                删除
                                                            </a>
                                                        </c:if>
                                                    </div>
                                                </td>
                                            </tr>
                                            <c:forEach items="${channelArea3.channelAreaList}" var="channelArea4">
                                                <tr style="display: none"
                                                    class="${channelArea.id} ${channelArea2.id} ${channelArea3.id}">
                                                    <td style="width: 250px;">${channelArea4.id}</td>
                                                    <td onclick="levelControl('${channelArea4.id}')"
                                                        style="padding-left: 68px; width: 380px; cursor: pointer">
                                                        <c:if test="${not empty channelArea4.channelAreaList}">
                                                            <span style="margin-right: 15px;cursor: pointer"
                                                                  id="${channelArea4.id}">△</span>
                                                        </c:if>
                                                            ${channelArea4.name }
                                                    </td>
                                                    <td style="width: 380px;">${channelArea4.pname}</td>
                                                    <td style="width: 380px;">四级</td>
                                                    <td style="width: 80px;">
                                                        <div class='hidden-phone visible-desktop btn-group'>
                                                            <c:if test="${fn:contains(butSet, 'edit')}">
                                                                <a class='btn btn-mini btn-info' title="编辑"
                                                                   onclick="edit('${channelArea4.id }');">
                                                                    编辑
                                                                </a>
                                                            </c:if>
                                                            <c:if test="${fn:contains(butSet, 'del')}">
                                                                <a class='btn btn-mini btn-danger' title="删除"
                                                                   onclick="del('${channelArea4.id }','${channelArea4.name }');">
                                                                    删除
                                                                </a>
                                                            </c:if>
                                                        </div>
                                                    </td>
                                                </tr>
                                                <c:forEach items="${channelArea4.channelAreaList}" var="channelArea5">
                                                    <tr style="display: none"
                                                        class="${channelArea.id} ${channelArea2.id} ${channelArea3.id} ${channelArea4.id}">
                                                        <td style="width: 250px;">${channelArea5.id}</td>
                                                        <td style="padding-left: 88px; width: 380px;">${channelArea5.name }</td>
                                                        <td style="width: 380px;">${channelArea5.pname}</td>
                                                        <td style="width: 380px;">五级</td>
                                                        <td style="width: 80px;">
                                                            <div class='hidden-phone visible-desktop btn-group'>
                                                                <c:if test="${fn:contains(butSet, 'edit')}">
                                                                    <a class='btn btn-mini btn-info' title="编辑"
                                                                       onclick="edit('${channelArea5.id }');">
                                                                        编辑
                                                                    </a>
                                                                </c:if>
                                                                <c:if test="${fn:contains(butSet, 'del')}">
                                                                    <a class='btn btn-mini btn-danger' title="删除"
                                                                       onclick="del('${channelArea5.id }','${channelArea5.name }');">
                                                                        删除
                                                                    </a>
                                                                </c:if>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </c:forEach>
                                            </c:forEach>
                                        </c:forEach>
                                    </c:forEach>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr class="main_info">
                                    <td colspan="10" class="center">没有相关数据</td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                        </tbody>
                    </table>
                    <div class="page-header position-relative">
                        <table style="width:100%;">
                            <tr>
                                <td style="vertical-align:top;">
                                    <div class="pagination"
                                         style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </form>
            </div>
        </div><!--/row-->
    </div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
    <i class="icon-double-angle-up icon-only"></i>
</a>
<!-- 引入 -->
<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/ace-elements.min.js"></script>
<script src="static/js/ace.min.js"></script>

<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
<!-- 引入 -->
<script type="text/javascript" src="static/js/jquery.tips.js"></script><!--提示框-->

<script type="text/javascript">
    $(top.hangge());

    //新增
    function add() {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "新增区域";
        diag.URL = '<%=basePath%>channelArea/toAdd';
        diag.Width = 500;
        diag.Height = 600;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                if ('${page.currentPage}' == '0') {
                    top.jzts();
                    $("#userForm").submit();
                } else {
                    nextPage(${page.currentPage});
                }
            }
            diag.close();
        };
        diag.show();
    }

    //修改
    function edit(id) {
        top.jzts();
        var diag = new top.Dialog();
        diag.Drag = true;
        diag.Title = "编辑区域";
        diag.URL = '<%=basePath%>channelArea/toEdit?id=' + id;
        diag.Width = 500;
        diag.Height = 600;
        diag.CancelEvent = function () { //关闭事件
            if (diag.innerFrame.contentWindow.document.getElementById('zhongxin').style.display == 'none') {
                nextPage(${page.currentPage});
            }
            diag.close();
        };
        diag.show();
    }

    //删除
    function del(id, name) {
        bootbox.confirm("是否删除[" + name + "]?", function (result) {
            if (result) {
                top.jzts();
                var url = "<%=basePath%>channelArea/del";
                var postParam = {"id": id};
                $.post(url, postParam, function (data) {
                    if (data.code == 200) {
                        nextPage(${page.currentPage});
                    } else {
                        alert(data.msg)
                    }
                });
            }
        });
    }

    function levelControl(id) {
        if (id) {
            if ($("." + id).css("display") == 'none') {
                $("." + id).css("display", "table-row");
                $("#" + id).html("▽");
            } else {
                $("." + id).css("display", "none");
                $("#" + id).html("△");
            }
        }
    }

</script>

<script type="text/javascript">
    $(function () {
        //下拉框
        $(".chzn-select").chosen({disable_search: true});
        $(".chzn-select-deselect").chosen({allow_single_deselect: true});
    });
</script>
</body>
</html>

